package com.xyrl.third.aliyun.util;

import com.xyrl.common.util.StringUtil;

/**
 * alioss 工具类
 *
 * @author zhongp
 * @version 1.0
 * @className OssUtil
 * @company 星纭融链科技服务有限公司
 * @date 2020-01-05 15:19:05
 * @Description
 */
public class OssUtil {
    private static String urlPath = "https://{bucketName}.oss-cn-beijing.aliyuncs.com";

    /**
     * 生成附件外网预览地址
     *
     * @param bucketName bucket 名称
     * @param path       附件路径
     * @return
     */
    public static String showUrl(String bucketName, String path) {
        if (!path.startsWith("/")) {
            path = StringUtil.concat("/", path);
        }
        String url = urlPath.replace("{bucketName}", bucketName);
        return StringUtil.concat(url, path);
    }

}
